package com.zhnc.dangjianpingtaiapp.argum;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.Toast;

import com.wangdh.utilslibrary.utils.logger.TLog;
import com.zhnc.dangjianpingtaiapp.R;
import com.zhnc.dangjianpingtaiapp.action.ActionButton;
import com.zhnc.dangjianpingtaiapp.utils.DialogHelper;
import com.zhnc.dangjianpingtaiapp.utils.recycler.RecyclerCommonAdapter;
import com.zhnc.dangjianpingtaiapp.utils.recycler.RecyclerViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangdh
 * @time 2019/4/4 13:31
 * @describe
 */
public class GridDataHelp {
    /**
     * @param activity 上下文
     * @param tag      依附目标
     * @return
     */
    public static ItemGridRely _dangwu(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(false);
        rely.setShowLine(false);
        rely.setMoreClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(activity, "点击了更多》》》》", Toast.LENGTH_SHORT).show();
            }
        });
        ArrayList<ActionButton> data = new ArrayList<>();
        ActionButton q1 = new ActionButton("要闻快递", R.mipmap.ic_launcher);
        q1.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Toast.makeText(activity, "点击了快递要闻", Toast.LENGTH_SHORT).show();
            }
        });
        data.add(q1);
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));
        data.add(new ActionButton("要闻快递", R.mipmap.ic_launcher));

        RecyclerCommonAdapter<ActionButton> adapter = new RecyclerCommonAdapter<ActionButton>(activity, R.layout.item_grid_btn, data) {
            @Override
            public void updataUI(RecyclerViewHolder recyclerViewHolder, ActionButton s) {
                recyclerViewHolder.setText(R.id.itme_test_text, s.getName());
                recyclerViewHolder.setOnClickListener(R.id.item_gird_ioc, s.getListener());
            }
        };
        rely.setAdapter(adapter);
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely _zhengwu1(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(false);
        rely.setShowLine(false);

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("办件查询", R.mipmap.ic_launcher));
        data.add(new ActionButton("咨询投诉", R.mipmap.ic_launcher));
        data.add(new ActionButton("政务热线", R.mipmap.ic_launcher));
        data.add(new ActionButton("公共资源", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely _zhengwu2(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("政务部门");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));
        data.add(new ActionButton("名字", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static RecyclerCommonAdapter getComAdapter(final Context context, List<ActionButton> data) {
        RecyclerCommonAdapter<ActionButton> adapter = new RecyclerCommonAdapter<ActionButton>(context, R.layout.item_grid_btn, data) {
            @Override
            public void updataUI(RecyclerViewHolder recyclerViewHolder, ActionButton s) {
                recyclerViewHolder.setText(R.id.itme_test_text, s.getName());
                View.OnClickListener listener = s.getListener();
                if (listener == null) {
                    recyclerViewHolder.setOnClickListener(R.id.item_gird_ioc, new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogHelper.getHintDialog(context, "温馨提示", "功能未开放", null);
                        }
                    });
                } else {
                    recyclerViewHolder.setOnClickListener(R.id.item_gird_ioc, listener);
                }
            }
        };
        return adapter;
    }

    public static ItemGridRely shehui1(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("便民服务");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely shehui2(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("就业服务");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("服务2", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务2", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务2", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务2", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely shehui3(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("卫生医疗");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("服务3", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务3", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务3", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务3", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely shehui4(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("农情发布");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("服务4", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务4", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务4", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务4", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务4", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }

    public static ItemGridRely shehui5(final Activity activity, Object tag) {
        ItemGridRely rely = new ItemGridRely();
        rely.setShowTitle(true);
        rely.setShowLine(false);
        rely.setTitleName("全域旅游");

        ArrayList<ActionButton> data = new ArrayList<>();

        data.add(new ActionButton("服务5", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务5", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务5", R.mipmap.ic_launcher));
        data.add(new ActionButton("服务5", R.mipmap.ic_launcher));

        rely.setAdapter(getComAdapter(activity, data));
        rely.setButtons(data);
        return rely;
    }
}
